package com.flyco.modules.stm.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.flyco.common.api.vo.Result;
import com.flyco.common.system.query.QueryGenerator;
import com.flyco.common.aspect.annotation.AutoLog;
import com.flyco.common.util.oConvertUtils;
import com.flyco.modules.stm.entity.StmStoreProductStock;
import com.flyco.modules.stm.service.IStmStoreProductStockService;

import java.util.Date;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.flyco.common.system.base.controller.BaseController;
import com.flyco.poi.excel.ExcelImportUtil;
import com.flyco.poi.excel.def.NormalExcelConstants;
import com.flyco.poi.excel.entity.ExportParams;
import com.flyco.poi.excel.entity.ImportParams;
import com.flyco.poi.excel.view.EntityExcelView;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @Description: 门店商品库存表
 * @Author: flyco
 * @Date: 2024-01-03
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "门店商品库存表")
@RestController
@RequestMapping("/f/stm/stmStoreProductStock")
public class StmStoreProductStockController extends BaseController<StmStoreProductStock, IStmStoreProductStockService> {

    @Autowired
    private IStmStoreProductStockService stmStoreProductStockService;

    /**
     * 分页列表查询
     *
     * @param stmStoreProductStock
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "门店商品库存表-分页列表查询")
    @ApiOperation(value = "门店商品库存表-分页列表查询", notes = "门店商品库存表-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(StmStoreProductStock stmStoreProductStock,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<StmStoreProductStock> queryWrapper = QueryGenerator.initQueryWrapper(stmStoreProductStock, req.getParameterMap());
        Page<StmStoreProductStock> page = new Page<StmStoreProductStock>(pageNo, pageSize);
        IPage<StmStoreProductStock> pageList = stmStoreProductStockService.page(page, queryWrapper);
        return Result.ok(pageList);
    }


    @AutoLog(value = "初始化门店商品库存")
    @ApiOperation(value = "初始化门店商品库存", notes = "初始化门店商品库存")
    @GetMapping(value = "/init")
    public Result<?> init() {

        stmStoreProductStockService.init();
        return Result.ok("初始化完成");
    }

}
